-
Notifications
You must be signed in to change notification settings - Fork 9
chore: update devcontainer docker image #208
Conversation
Dockerfile
Outdated
RUN export PATH="$DPRINT_INSTALL/bin:$PATH" | ||
RUN /bin/bash -c 'curl -fsSL https://deno.land/x/install/install.sh | sh \ | ||
&& curl -fsSL https://dprint.dev/install.sh | sh \ | ||
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only used for cspell
.
An alternative installation method could be to use node from NodeSource
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we still need to set up Node in order for Prettier and other devcontained extensions to work properly. I stackoverflowed this over a year ago. The answer is subpar. @tjjfvi any recommendations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not familiar with docker, but the setup seems fine to me 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to use https://deb.nodesource.com/setup_18.x
so we don't need to create a non-root user to run nvm
.
Note: this would be an alternative to setup nvm as a root or non-root user https://github.com/microsoft/vscode-dev-containers/blob/v0.195.0/containers/javascript-node/.devcontainer/base.Dockerfile#L10
1a88635
to
349eb05
Compare
.gitpod.Dockerfile
Outdated
# Gitpod creates a gitpod user to run without privileges | ||
# following https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user | ||
ENV DENO_DIR=/home/gitpod/.deno |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I duplicated the Dockerfile
as workaround for Gitpod.
Gitpod runs deno (or any script) as non-root user gitpod
.
Setting DENO_DIR
allows the gitpod
user to store deno cache files in a folder where gitpod
has write permissions.
Unfortunately, Gitpod, does not support docker multi-stage builds (see issue). With multi-stage support, a single Dockerfile could be used to target a build for Gitpod.
"editor.defaultFormatter": "dprint.dprint", | ||
"editor.formatOnSave": true, | ||
"editor.tabSize": 2, | ||
"prettier.printWidth": 100 | ||
}, | ||
"extensions": [ | ||
"EditorConfig.EditorConfig", | ||
"bungcip.better-toml", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get rid of this as well, as I believe we no longer have any toml in this repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a book.toml
file.
Shall I remove it anyway?
file: Dockerfile | ||
file: .gitpod.Dockerfile | ||
tasks: | ||
- init: deno task star | ||
vscode: | ||
extensions: | ||
- EditorConfig.EditorConfig | ||
- bungcip.better-toml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
@harrysolovay Did you rebuild the container? I'm not able to reproduce
|
RUN export PATH=/usr/local/cargo/bin:$PATH | ||
RUN export DPRINT_INSTALL="/home/vscode/.dprint" | ||
RUN export PATH="$DPRINT_INSTALL/bin:$PATH" | ||
FROM vscode as gitpod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gitpod does not support multistage builds but VSCode devcontainer extension supports multi stage builds.
With this setup
- gitpod, uses the last stage to configure the container image
- devcontainer, uses the
vscode
stage configured indevcontainer.json
Do we want to remove this line as well and add a badge such as this? |
@harrysolovay this is badge ready now 🎉 |
* chore: update devcontainer docker image * chore: remove rust extension from devcontainer.json and .gitpod.yml * chore: update Dockerfile base image to denoland/deno * chore: add custom docker image for Gitpod * chore: unset DENO_DIR for Gitpod * chore: set deno as container user * chore: add multistage container * chore: add polkadot binary * chore: update Readme * feat: update docker image to download polkadot from GH releases
Closes #41
Updates devcontainer docker image to install the following tools as
vscode
userdeno
dprint
node
(needed forcspell
)cspell
Developer test plan
Using VSCode, start the project in a container
.ts
file, and try go to Class/Interface definitions in other files usingF12
(orcommand + click
).ts
file, add many line breaks, and validate thatdprint
with the VSCode extension formats the textcspell "**/*"
polkadot -V
deno task run examples/transfer.ts
Using Gitpod, try the previous steps in
Ideas
As a follow up, we could create another image with the✅ donepolkadot
binary, so it can be used withtest-util/config.ts